package com.example.cloud.alibaba.seata.storage.service;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.cloud.alibaba.seata.common.dto.CommodityDTO;
import com.example.cloud.alibaba.seata.common.utils.SimpleMessage;
import com.example.cloud.alibaba.seata.storage.entity.TStorage;
import com.example.cloud.alibaba.seata.storage.mapper.TStorageMapper;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  库存服务实现类
 * </p>
 *
 * * @author lidong
 * @since 2019-09-04
 */
@Service
public class TStorageServiceImpl extends ServiceImpl<TStorageMapper, TStorage> implements ITStorageService {

    @Override
    public SimpleMessage decreaseStorage(CommodityDTO commodityDTO) {
        int storage = baseMapper.decreaseStorage(commodityDTO.getCommodityCode(), commodityDTO.getCount());
        if (storage > 0){
            return SimpleMessage.info("扣减库存成功~");
        }
        return SimpleMessage.fail("扣减库存失败!");
    }
}
